package com.xdtech.sys.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.xdtech.core.model.BaseItem;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.Role;
import com.xdtech.web.freemark.item.GridColumn;

public class RoleItem  extends BaseItem implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private Long id;
	@GridColumn(title="角色名称",width=100)
	private String name;
	@GridColumn(title="是否启用",dictionaryCode="YON")
	private boolean enable;
	@GridColumn(title="角色编码",width=120)
	private String code; 
	@GridColumn(title="角色描述",width=200)
	private String description;
	@GridColumn(title="是否超级管理员",dictionaryCode="YON",width=100)
	private boolean superuser;  
	private String linkType;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public boolean isEnable() {
		return enable;
	}
	public void setEnable(boolean enable) {
		this.enable = enable;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public boolean isSuperuser() {
		return superuser;
	}
	public void setSuperuser(boolean superuser) {
		this.superuser = superuser;
	}
	

	public String getLinkType() {
		return linkType;
	}
	public void setLinkType(String linkType) {
		this.linkType = linkType;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<RoleItem> createItems(List<Role> roles) {
		List<RoleItem> roleItems = new ArrayList<RoleItem>();
		for (Role role : roles) {
			roleItems.add(createItem(role));
		}
		return roleItems;
	}
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static RoleItem createItem(Role role) {
		RoleItem roleItem = null;
		if(roleItem!=null) {
			roleItem = new RoleItem();
			BeanUtils.copyProperties(roleItem, role);
			//自定义属性设置填充
		}
		return roleItem;
	}
	
	/**
	 * 转model
	 * @return
	 */
	public Role toModel() {
		Role model = new Role();
		BeanUtils.copyProperties(model, this);
		return model;
	}
	

}
